/*
 * @Author: gaoyu gy15354315043@163.com
 * @Date: 2024-11-08 10:23:06
 * @LastEditors: gaoyu gy15354315043@163.com
 * @LastEditTime: 2024-11-15 14:33:16
 * @Description: 
 * Copyright (c) 2024-present HBIS Digital Technology Co.,Ltd. All rights reserved. 
 */
import { default as request, cloud } from '@/framework/utils/request';
import { ResultData } from '@/framework/api/common';
import { collectMenuList, menuDetail, menuTree, treeData, appList } from './types'
/**
 * @description: 添加收藏
 * @param {Partial} params
 * @return {*}
 */
export function addCollectMenu(data: Partial<menuDetail>): Promise<ResultData<null>> {
    return request({
        url: `${cloud.businessBasic}/portal/collectMenu/add`,
        method: 'post',
        data
    })
}
/**
 * @description: 取消收藏
 * @param {Partial} params
 * @return {*}
 */
export function deleteCollectMenu(data: Partial<menuDetail>): Promise<ResultData<null>> {
    return request({
        url: `${cloud.businessBasic}/portal/collectMenu/delete`,
        method: 'post',
        data
    })
}
/**
 * @description: 查询当前登录用户收藏菜单列表
 * @return {*}
 */
export function getCollectMenuList(): Promise<ResultData<collectMenuList[]>> {
    return request({
        url: `${cloud.businessBasic}/portal/collectMenu/getList`,
        method: 'get',
    })
}

// 记录当前登录用户最近访问的应用
export function addRecentVisitApp(data: Partial<menuDetail>): Promise<ResultData<null>> {
    return request({
        url: `${cloud.businessBasic}/portal/recentVisitApp/add`,
        method: 'post',
        data
    })
}
/**
 * @description: 获取当前登录用户最近访问的应用列表
 * @return {*}
 */
export function getRecentVisitAppList(): Promise<ResultData<appList[]>> {
    return request({
        url: `${cloud.businessBasic}/portal/recentVisitApp/getList`,
        method: 'get',
    })
}
/**
 * @description: 获取当前登录用户有权限的应用列表
 * @return {*}
 */
export function getLoginUserApp(): Promise<ResultData<treeData[]>> {
    return request({
        url: `${cloud.businessBasic}/portal/getLoginUserApp`,
        method: 'get',
    })
}
/**
 * @description: 获取收藏菜单选择数据
 * @return {*}
 */
export function getCollectMenuSelector(params: Partial<menuDetail>): Promise<ResultData<menuTree[]>> {
    return request({
        url: `${cloud.businessBasic}/portal/getCollectMenuSelector`,
        method: 'get',
        params
    })
}
/**
 * @description: 统一导航-调整收藏排序
 * @return {*}
 */
export function updateSort(collectMenuList: collectMenuList[]): Promise<ResultData<null>> {
    return request({
        url: `${cloud.businessBasic}/portal/collectMenu/updateSort`,
        method: 'post',
        data: {
            collectMenuList: collectMenuList
        }
    })
}
